package lang

import "fmt"
import "time"

var (
	JobTicker    time.Ticker
	tickerStopChannel = make(chan bool)
)

func mainTicker() {
	JobTicker = *time.NewTicker(300 * time.Millisecond)
	go ticker()
	stopTicker()
}

func ticker() {
	for {
		select {
		case timeticker := <-JobTicker.C:
			fmt.Println("The time for current is : ", timeticker)
		case <-tickerStopChannel:
			return
		}
	}
}

func stopTicker() {
	time.Sleep(600 * time.Millisecond)
	JobTicker.Stop()
	tickerStopChannel <- true
	fmt.Println("Time for running ticker is completed")
}
